package com.example.myblog.mapper;

import com.example.myblog.entity.Article;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * <p>
 *  Mapper 接口
 * </p>
 *
 * @author 廖老师
 * @since 2023-06-27
 */
public interface ArticleMapper extends BaseMapper<Article> {

    @Select("select a.*," +
            " b.id as \"category.id\"," +
            " b.name as \"category.name\"," +
            " b.sort as \"category.sort\"," +
            " b.introduce as \"category.introduce\"" +
            " from article a" +
            " join category b on a.categoryId=b.id" +
            " limit ${begin}, ${size}")
    List<Article> selectNew(@Param("begin") int begin, @Param("size") int size);

}
